Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /** |
||
100 | describe("Check gamebrain", function() { |
||
101 | var cardvalues = [ |
||
102 | {player: "Magnus", colorclass: "blueplayer", cardvalue: "alpaca.png", expectedcardvalues: ["alpaca.png"]}, |
||
103 | ]; |
||
104 | |||
105 | var uniqifynames = [ |
||
106 | {nicknameone: "Magnus", nicknametwo: "Magnus", nicknamethree: "", expected: "Magnus2"}, |
||
107 | {nicknameone: "Magnus", nicknametwo: "Magnus", nicknamethree: "Magnus2", expected: "Magnus3"}, |
||
108 | {nicknameone: "Magnus", nicknametwo: "Roger", nicknamethree: "", expected: "Roger"} |
||
109 | ]; |
||
110 | |||
111 | var setactive = [ |
||
112 | {players: ["a", "b", "c"]} |
||
113 | ]; |
||
114 | |||
115 | var setcolor = [ |
||
116 | {players: ["a", "b", "c"]} |
||
117 | ]; |
||
118 | |||
119 | // var cardids = [ |
||
120 | // {value: 0, expected: [-1, -1]}, |
||
121 | // {value: 300, expected: [-1, -1]}, |
||
122 | // {value: 1, expected: [0, 1]}, |
||
123 | // {value: 2, expected: [2, 3]}, |
||
124 | // {value: 3, expected: [4, 5]} |
||
125 | // ]; |
||
126 | |||
127 | cardvalues.forEach(function(test) { |
||
128 | describe("Set card values in gamebrain", function() { |
||
129 | it("Checking values", function () { |
||
130 | checkSetCardValue(test.player, test.colorclass, test.cardvalue, test.expectedcardvalues); |
||
131 | }); |
||
132 | }); |
||
133 | }); |
||
134 | |||
135 | uniqifynames.forEach(function(test) { |
||
136 | describe("Check uniqifying names " + test.nicknameone +" with " + test.nicknametwo, function() { |
||
137 | it("Second nickname should be " + test.expected, function () { |
||
138 | checkUniqifining(test.nicknameone, test.nicknametwo, test.nicknamethree, test.expected); |
||
139 | }); |
||
140 | }); |
||
141 | }); |
||
142 | |||
143 | setactive.forEach(function(test) { |
||
144 | describe("Check set active player", function() { |
||
145 | it("Checking next player", function () { |
||
146 | checkSetActivePlayer(test.players); |
||
147 | }); |
||
148 | }); |
||
149 | }); |
||
150 | |||
151 | setcolor.forEach(function(test) { |
||
152 | describe("Check set color for player", function() { |
||
153 | it("Checking color", function () { |
||
154 | checkSetPlayerColor(test.players); |
||
155 | }); |
||
156 | }); |
||
157 | }); |
||
158 | }); |
||
159 |